/** *通用形列表-弹框部分 */
<template>
    <!-- 必须加一个div。不然高度被拉满了 -->
    <div>
        <el-dialog
            v-model="dialogObj.dialogVisible"
            :title="`${route.meta.title} —— ${dialogObj.dialogTitle}`"
            width="85%"
            center
            align-center
            destroy-on-close
            draggable
            overflow
            :close-on-click-modal="false"
            class="my-dialog"
            :before-close="beforeClose"
        >
            <!-- <span>This is a message</span>
            <template #footer>
                <div class="dialog-footer">
                    <el-button @click="dialogObj.dialogVisible = false">Cancel</el-button>
                    <el-button type="primary" @click="dialogObj.dialogVisible = false">
                        Confirm
                    </el-button>
                </div>
            </template> -->
            <component :is="dialogObj.dialogComponent" v-model:dialogObj="dialogObj" @tableSearch="tableSearch" />
        </el-dialog>
    </div>
</template>

<script lang="ts" setup>
    import { useRoute, useRouter } from 'vue-router';
    import { useStore } from '@/store';
    const route = useRoute();
    const dialogObj = defineModel<any>('dialogObj', {
        required: false,
        default: {
            dialogTitle: false, //dialog标题
            dialogVisible: false, //dialog显示
            dialogComponent: '', //组件
            dialogParams: {}, //组件参数
        },
    });
    const emits = defineEmits<{
        // (e: 'update:isCollapse', data: boolean): void,
        tableSearch: [data: any];
    }>();
    const tableSearch = (val) => {
        emits('tableSearch', val);
    };
    const beforeClose = (done) => {
        // dialogObj.value.dialogComponent = ''
        done();
    };
</script>

<style lang="scss" scoped>
    :deep(.my-dialog) {
        height: 90%;
        overflow: hidden;
        .el-dialog__body {
            height: 95%;
            // overflow-x: hidden;
            // overflow-y: scroll;
        }
    }
</style>
